home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / term-source.lha / Extras / Source / term-Source.lha / PatternPanel.c < prev    next >
C/C++ Source or Header  |  1995-02-07  |  23KB  |  1,003 lines

  1. /*
  2. **    PatternPanel.c
  3. **
  4. **    Editing panel for phone number patterns
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. **
  9. ** :ts=4
  10. */
  11.  
  12. #include "termGlobal.h"
  13.  
  14. enum    {    GAD_LIST,GAD_COMMENT,GAD_PATTERN,
  15.             GAD_TOP,GAD_UP,GAD_DOWN,GAD_END,
  16.             GAD_NEW,GAD_REMOVE,GAD_CLEAR,
  17.             GAD_EDIT,
  18.             GAD_LOAD,GAD_SAVE,GAD_USE
  19.         };
  20.  
  21. VOID
  22. PatternPanel()
  23. {
  24.     STATIC LONG ButtonID[] =
  25.     {
  26.         MSG_FASTMACROPANEL_NEW_GAD,
  27.         MSG_GLOBAL_REMOVE_GAD,
  28.         MSG_UPLOADQUEUE_CLEAR_TXT,
  29.         MSG_V36_0043
  30.     };
  31.  
  32.     struct LayoutHandle *Handle;
  33.     struct PatternNode    *Node;
  34.     LONG                 ListCount;
  35.     struct List         *PhoneList;
  36.     WORD                 i,Max,Len;
  37.  
  38.     PhoneList = CreatePhoneList();
  39.  
  40.     ListCount = GetListSize(PatternList);
  41.  
  42.     if(Handle = LT_CreateHandleTags(Window -> WScreen,
  43.         LH_LocaleHook,    &LocaleHook,
  44.     TAG_DONE))
  45.     {
  46.         struct Window    *LocalWindow;
  47.         struct IBox     Bounds;
  48.  
  49.         for(i = Max = 0 ; i < 4 ; i++)
  50.         {
  51.             if((Len = LT_LabelChars(Handle,LocaleString(ButtonID[i]))) > Max)
  52.                 Max = Len;
  53.         }
  54.  
  55.         LT_New(Handle,
  56.             LA_Type,    VERTICAL_KIND,
  57.         TAG_DONE);
  58.         {
  59.             LT_New(Handle,
  60.                 LA_Type,        VERTICAL_KIND,
  61.                 LA_LabelID,     MSG_AREACODE_GROUPS_TXT,
  62.             TAG_DONE);
  63.             {
  64.                 LT_New(Handle,
  65.                     LA_Type,        LISTVIEW_KIND,
  66.                     LA_LabelID,     MSG_AREACODE_GROUPS_GAD,
  67.                     LA_LabelPlace,    PLACE_LEFT,
  68.                     LA_Chars,        30,
  69.                     LA_Lines,        10,
  70.                     LA_ID,            GAD_LIST,
  71.                     LALV_CursorKey, TRUE,
  72.                     LALV_ResizeX,    TRUE,
  73.                     LALV_ResizeY,    TRUE,
  74.                     LALV_MaxGrowY,    20,
  75.                     LALV_MaxGrowX,    50,
  76.                     GTLV_Labels,    PatternList,
  77.  
  78.                     Kick30 ? LALV_Link : TAG_IGNORE, NIL_LINK,
  79.                 TAG_DONE);
  80.  
  81.                 LT_New(Handle,
  82.                     LA_Type,        STRING_KIND,
  83.                     LA_LabelID,     MSG_AREACODE_NAME_GAD,
  84.                     LA_ID,            GAD_COMMENT,
  85.                     GTST_MaxChars,    39,
  86.                     GA_Disabled,    TRUE,
  87.                 TAG_DONE);
  88.  
  89.                 LT_New(Handle,
  90.                     LA_Type,        STRING_KIND,
  91.                     LA_LabelID,     MSG_AREACODE_PATTERN_GAD,
  92.                     LA_ID,            GAD_PATTERN,
  93.                     GTST_MaxChars,    255,
  94.                     GA_Disabled,    TRUE,
  95.                 TAG_DONE);
  96.  
  97.                 LT_EndGroup(Handle);
  98.             }
  99.  
  100.             LT_New(Handle,
  101.                 LA_Type,    HORIZONTAL_KIND,
  102.             TAG_DONE);
  103.             {
  104.                 LT_New(Handle,
  105.                     LA_Type,        VERTICAL_KIND,
  106.                     LA_LabelID,     MSG_V36_0038,
  107.                 TAG_DONE);
  108.                 {
  109.                     LT_New(Handle,
  110.                         LA_Type,        HORIZONTAL_KIND,
  111.                         LA_SameSize,    TRUE,
  112.                     TAG_DONE);
  113.                     {
  114.                         LT_New(Handle,
  115.                             LA_Type,            TAPEDECK_KIND,
  116.                             LATD_ButtonType,    TDBT_PREVIOUS,
  117.                             LATD_Smaller,        TRUE,
  118.                             LA_ID,                GAD_TOP,
  119.                             LA_NoKey,            TRUE,
  120.                             GA_Disabled,        TRUE,
  121.                         TAG_DONE);
  122.  
  123.                         LT_New(Handle,
  124.                             LA_Type,            TAPEDECK_KIND,
  125.                             LATD_ButtonType,    TDBT_NEXT,
  126.                             LATD_Smaller,        TRUE,
  127.                             LA_ID,                GAD_END,
  128.                             LA_NoKey,            TRUE,
  129.                             GA_Disabled,        TRUE,
  130.                         TAG_DONE);
  131.  
  132.                         LT_EndGroup(Handle);
  133.                     }
  134.  
  135.                     LT_New(Handle,
  136.                         LA_Type,        HORIZONTAL_KIND,
  137.                         LA_SameSize,    TRUE,
  138.                     TAG_DONE);
  139.                     {
  140.                         LT_New(Handle,
  141.                             LA_Type,            TAPEDECK_KIND,
  142.                             LATD_ButtonType,    TDBT_REWIND,
  143.                             LATD_Smaller,        TRUE,
  144.                             LA_ID,                GAD_UP,
  145.                             LA_NoKey,            TRUE,
  146.                             GA_Disabled,        TRUE,
  147.                         TAG_DONE);
  148.  
  149.                         LT_New(Handle,
  150.                             LA_Type,            TAPEDECK_KIND,
  151.                             LATD_ButtonType,    TDBT_PLAY,
  152.                             LATD_Smaller,        TRUE,
  153.                             LA_ID,                GAD_DOWN,
  154.                             LA_NoKey,            TRUE,
  155.                             GA_Disabled,        TRUE,
  156.                         TAG_DONE);
  157.  
  158.                         LT_EndGroup(Handle);
  159.                     }
  160.  
  161.                     LT_EndGroup(Handle);
  162.                 }
  163.  
  164.                 LT_New(Handle,
  165.                     LA_Type,        VERTICAL_KIND,
  166.                     LA_LabelID,     MSG_V36_0043,
  167.                 TAG_DONE);
  168.                 {
  169.                     LT_New(Handle,
  170.                         LA_Type,        HORIZONTAL_KIND,
  171.                         LA_SameSize,    TRUE,
  172.                     TAG_DONE);
  173.                     {
  174.                         LT_New(Handle,
  175.                             LA_Type,        BUTTON_KIND,
  176.                             LA_LabelID,     MSG_FASTMACROPANEL_NEW_GAD,
  177.                             LA_ID,            GAD_NEW,
  178.                             LA_Chars,        Max,
  179.                         TAG_DONE);
  180.  
  181.                         LT_New(Handle,
  182.                             LA_Type,        BUTTON_KIND,
  183.                             LA_LabelID,     MSG_GLOBAL_REMOVE_GAD,
  184.                             LA_ID,            GAD_REMOVE,
  185.                             GA_Disabled,    TRUE,
  186.                             LA_Chars,        Max,
  187.                         TAG_DONE);
  188.  
  189.                         LT_EndGroup(Handle);
  190.                     }
  191.  
  192.                     LT_New(Handle,
  193.                         LA_Type,        HORIZONTAL_KIND,
  194.                         LA_SameSize,    TRUE,
  195.                     TAG_DONE);
  196.                     {
  197.                         LT_New(Handle,
  198.                             LA_Type,        BUTTON_KIND,
  199.                             LA_LabelID,     MSG_UPLOADQUEUE_CLEAR_TXT,
  200.                             LA_ID,            GAD_CLEAR,
  201.                             GA_Disabled,    PatternList -> lh_Head -> ln_Succ == NULL,
  202.                             LA_Chars,        Max,
  203.                         TAG_DONE);
  204.  
  205.                         LT_New(Handle,
  206.                             LA_Type,        BUTTON_KIND,
  207.                             LA_LabelID,     MSG_V36_0043,
  208.                             LA_ID,            GAD_EDIT,
  209.                             GA_Disabled,    TRUE,
  210.                             LA_Chars,        Max,
  211.                         TAG_DONE);
  212.  
  213.                         LT_EndGroup(Handle);
  214.                     }
  215.  
  216.                     LT_EndGroup(Handle);
  217.                 }
  218.  
  219.                 LT_EndGroup(Handle);
  220.             }
  221.  
  222.             LT_New(Handle,
  223.                 LA_Type,    VERTICAL_KIND,
  224.             TAG_DONE);
  225.             {
  226.                 LT_New(Handle,LA_Type,XBAR_KIND,LAXB_FullSize,TRUE,TAG_DONE);
  227.  
  228.                 LT_EndGroup(Handle);
  229.             }
  230.  
  231.             LT_New(Handle,LA_Type,HORIZONTAL_KIND,
  232.                 LAGR_SameSize,    TRUE,
  233.                 LAGR_Spread,    TRUE,
  234.                 LA_ExtraSpace,    TRUE,
  235.             TAG_DONE);
  236.             {
  237.                 LT_New(Handle,
  238.                     LA_Type,        BUTTON_KIND,
  239.                     LA_LabelID,     MSG_GLOBAL_USE_GAD,
  240.                     LA_ID,            GAD_USE,
  241.                     LABT_ReturnKey, TRUE,
  242.                     LABT_ExtraFat,    TRUE,
  243.                 TAG_DONE);
  244.  
  245.                 LT_New(Handle,
  246.                     LA_Type,        BUTTON_KIND,
  247.                     LA_LabelID,     MSG_GLOBAL_LOAD_GAD,
  248.                     LA_ID,            GAD_LOAD,
  249.                     LABT_ExtraFat,    TRUE,
  250.                     GA_Disabled,    ChosenPattern != NULL,
  251.                 TAG_DONE);
  252.  
  253.                 LT_New(Handle,
  254.                     LA_Type,        BUTTON_KIND,
  255.                     LA_LabelID,     MSG_GLOBAL_SAVE_GAD,
  256.                     LA_ID,            GAD_SAVE,
  257.                     LABT_ExtraFat,    TRUE,
  258.                     GA_Disabled,    PatternList -> lh_Head -> ln_Succ == NULL,
  259.                 TAG_DONE);
  260.  
  261.                 LT_EndGroup(Handle);
  262.             }
  263.  
  264.             LT_EndGroup(Handle);
  265.         }
  266.  
  267.         if(Screen && Window)
  268.         {
  269.             Bounds . Left    = Window -> LeftEdge;
  270.             Bounds . Top    = Window -> TopEdge;
  271.             Bounds . Width    = Window -> Width;
  272.             Bounds . Height = Window -> Height;
  273.         }
  274.  
  275.         if(LocalWindow = LT_Layout(Handle,LocaleString(MSG_AREACODE_GROUPS_TITLE),Screen ? &Bounds : NULL,0,0,IDCMP_CLOSEWINDOW,0,
  276.             LAWN_HelpHook,    &GuideHook,
  277.             LAWN_Parent,    Window,
  278.             WA_DepthGadget, TRUE,
  279.             WA_CloseGadget, TRUE,
  280.             WA_DragBar,     TRUE,
  281.             WA_RMBTrap,     TRUE,
  282.             WA_Activate,    TRUE,
  283.         TAG_DONE))
  284.         {
  285.             struct IntuiMessage     *Message;
  286.             BOOLEAN                  Done = FALSE;
  287.             ULONG                     MsgClass,
  288.                                      MsgQualifier;
  289.             UWORD                     MsgCode;
  290.             struct Gadget            *MsgGadget;
  291.  
  292.             struct PatternNode        *Selected = NULL;
  293.             ULONG                     Offset = 0;
  294.  
  295.             UBYTE                     DummyBuffer[MAX_FILENAME_LENGTH],
  296.                                     *DummyChar;
  297.             struct FileRequester    *FileRequest;
  298.             LONG                     Error;
  299.  
  300.             GuideContext(CONTEXT_AREA_CODES);
  301.  
  302.             PushWindow(LocalWindow);
  303.  
  304.             do
  305.             {
  306.                 if(Wait(PORTMASK(LocalWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  307.                     break;
  308.  
  309.                 while(Message = (struct IntuiMessage *)LT_GetIMsg(Handle))
  310.                 {
  311.                     MsgClass        = Message -> Class;
  312.                     MsgQualifier    = Message -> Qualifier;
  313.                     MsgCode         = Message -> Code;
  314.                     MsgGadget        = (struct Gadget *)Message -> IAddress;
  315.  
  316.                     LT_ReplyIMsg(Message);
  317.  
  318.                     if(MsgClass == IDCMP_CLOSEWINDOW)
  319.                         Done = TRUE;
  320.  
  321.                     if(MsgClass == IDCMP_IDCMPUPDATE)
  322.                     {
  323.                         if(MsgGadget -> GadgetID == GAD_LIST)
  324.                         {
  325.                             if(!Selected)
  326.                             {
  327.                                 if(Selected = (struct PatternNode *)GetListNode(MsgCode,(struct List *)PatternList))
  328.                                 {
  329.                                     Offset = MsgCode;
  330.  
  331.                                     LT_SetAttributes(Handle,GAD_COMMENT,
  332.                                         GTST_String,    Selected -> Comment,
  333.                                         GA_Disabled,    FALSE,
  334.                                     TAG_DONE);
  335.  
  336.                                     LT_SetAttributes(Handle,GAD_PATTERN,
  337.                                         GTST_String,    Selected -> Pattern,
  338.                                         GA_Disabled,    FALSE,
  339.                                     TAG_DONE);
  340.  
  341.                                     LT_SetAttributes(Handle,GAD_REMOVE,
  342.                                         GA_Disabled,    &Selected -> List == ChosenPattern,
  343.                                     TAG_DONE);
  344.  
  345.                                     LT_SetAttributes(Handle,GAD_EDIT,
  346.                                         GA_Disabled,    &Selected -> List == ChosenPattern,
  347.                                     TAG_DONE);
  348.  
  349.                                     LT_SetAttributes(Handle,GAD_TOP,
  350.                                         GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  351.                                     TAG_DONE);
  352.  
  353.                                     LT_SetAttributes(Handle,GAD_UP,
  354.                                         GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  355.                                     TAG_DONE);
  356.  
  357.                                     LT_SetAttributes(Handle,GAD_DOWN,
  358.                                         GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  359.                                     TAG_DONE);
  360.  
  361.                                     LT_SetAttributes(Handle,GAD_END,
  362.                                         GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  363.                                     TAG_DONE);
  364.                                 }
  365.                             }
  366.  
  367.                             if(Selected && (&Selected -> List != ChosenPattern))
  368.                             {
  369.                                 LT_PressButton(Handle,GAD_EDIT);
  370.  
  371.                                 LT_LockWindow(LocalWindow);
  372.  
  373.                                 PatternsChanged |= RatePanel(LocalWindow,PhoneList,NULL,&Selected -> List);
  374.  
  375.                                 LT_UnlockWindow(LocalWindow);
  376.                             }
  377.                         }
  378.                     }
  379.  
  380.                     if(MsgClass == IDCMP_GADGETUP)
  381.                     {
  382.                         switch(MsgGadget -> GadgetID)
  383.                         {
  384.                             case GAD_USE:
  385.  
  386.                                 Done = TRUE;
  387.                                 break;
  388.  
  389.                             case GAD_TOP:
  390.  
  391.                                 LT_SetAttributes(Handle,GAD_LIST,
  392.                                     GTLV_Labels,    ~0,
  393.                                 TAG_DONE);
  394.  
  395.                                 Remove((struct Node *)Selected);
  396.  
  397.                                 AddHead((struct List *)PatternList,(struct Node *)Selected);
  398.  
  399.                                 Offset = 0;
  400.  
  401.                                 LT_SetAttributes(Handle,GAD_LIST,
  402.                                     GTLV_Labels,    PatternList,
  403.                                     GTLV_Selected,    Offset,
  404.                                     GTLV_Top,        Offset,
  405.                                 TAG_DONE);
  406.  
  407.                                 LT_SetAttributes(Handle,GAD_TOP,
  408.                                     GA_Disabled,    TRUE,
  409.                                 TAG_DONE);
  410.  
  411.                                 LT_SetAttributes(Handle,GAD_UP,
  412.                                     GA_Disabled,    TRUE,
  413.                                 TAG_DONE);
  414.  
  415.                                 LT_SetAttributes(Handle,GAD_DOWN,
  416.                                     GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  417.                                 TAG_DONE);
  418.  
  419.                                 LT_SetAttributes(Handle,GAD_END,
  420.                                     GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  421.                                 TAG_DONE);
  422.  
  423.                                 PatternsChanged = TRUE;
  424.                                 break;
  425.  
  426.                             case GAD_UP:
  427.  
  428.                                 LT_SetAttributes(Handle,GAD_LIST,
  429.                                     GTLV_Labels,    ~0,
  430.                                 TAG_DONE);
  431.  
  432.                                 Node = (struct PatternNode *)Selected -> Node . ln_Pred -> ln_Pred;
  433.  
  434.                                 Remove((struct Node *)Selected);
  435.  
  436.                                 Insert((struct List *)PatternList,(struct Node *)Selected,(struct Node *)Node);
  437.  
  438.                                 Offset--;
  439.  
  440.                                 LT_SetAttributes(Handle,GAD_LIST,
  441.                                     GTLV_Labels,    PatternList,
  442.                                     GTLV_Selected,    Offset,
  443.                                     GTLV_Top,        Offset,
  444.                                 TAG_DONE);
  445.  
  446.                                 LT_SetAttributes(Handle,GAD_TOP,
  447.                                     GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  448.                                 TAG_DONE);
  449.  
  450.                                 LT_SetAttributes(Handle,GAD_UP,
  451.                                     GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  452.                                 TAG_DONE);
  453.  
  454.                                 LT_SetAttributes(Handle,GAD_DOWN,
  455.                                     GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  456.                                 TAG_DONE);
  457.  
  458.                                 LT_SetAttributes(Handle,GAD_END,
  459.                                     GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  460.                                 TAG_DONE);
  461.  
  462.                                 PatternsChanged = TRUE;
  463.  
  464.                                 break;
  465.  
  466.                             case GAD_DOWN:
  467.  
  468.                                 LT_SetAttributes(Handle,GAD_LIST,
  469.                                     GTLV_Labels,    ~0,
  470.                                 TAG_DONE);
  471.  
  472.                                 Node = (struct PatternNode *)Selected -> Node . ln_Succ;
  473.  
  474.                                 Remove((struct Node *)Selected);
  475.  
  476.                                 Insert((struct List *)PatternList,(struct Node *)Selected,(struct Node *)Node);
  477.  
  478.                                 Offset++;
  479.  
  480.                                 LT_SetAttributes(Handle,GAD_LIST,
  481.                                     GTLV_Labels,    PatternList,
  482.                                     GTLV_Selected,    Offset,
  483.                                     GTLV_Top,        Offset,
  484.                                 TAG_DONE);
  485.  
  486.                                 LT_SetAttributes(Handle,GAD_TOP,
  487.                                     GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  488.                                 TAG_DONE);
  489.  
  490.                                 LT_SetAttributes(Handle,GAD_UP,
  491.                                     GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  492.                                 TAG_DONE);
  493.  
  494.                                 LT_SetAttributes(Handle,GAD_DOWN,
  495.                                     GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  496.                                 TAG_DONE);
  497.  
  498.                                 LT_SetAttributes(Handle,GAD_END,
  499.                                     GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  500.                                 TAG_DONE);
  501.  
  502.                                 PatternsChanged = TRUE;
  503.  
  504.                                 break;
  505.  
  506.                             case GAD_END:
  507.  
  508.                                 LT_SetAttributes(Handle,GAD_LIST,
  509.                                     GTLV_Labels,    ~0,
  510.                                 TAG_DONE);
  511.  
  512.                                 Remove((struct Node *)Selected);
  513.  
  514.                                 AddTail((struct List *)PatternList,(struct Node *)Selected);
  515.  
  516.                                 Offset = ListCount - 1;
  517.  
  518.                                 LT_SetAttributes(Handle,GAD_LIST,
  519.                                     GTLV_Labels,    PatternList,
  520.                                     GTLV_Selected,    Offset,
  521.                                     GTLV_Top,        Offset,
  522.                                 TAG_DONE);
  523.  
  524.                                 LT_SetAttributes(Handle,GAD_TOP,
  525.                                     GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  526.                                 TAG_DONE);
  527.  
  528.                                 LT_SetAttributes(Handle,GAD_UP,
  529.                                     GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  530.                                 TAG_DONE);
  531.  
  532.                                 LT_SetAttributes(Handle,GAD_DOWN,
  533.                                     GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  534.                                 TAG_DONE);
  535.  
  536.                                 LT_SetAttributes(Handle,GAD_END,
  537.                                     GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  538.                                 TAG_DONE);
  539.  
  540.                                 PatternsChanged = TRUE;
  541.  
  542.                                 break;
  543.  
  544.                             case GAD_NEW:
  545.  
  546.                                 if(Node = CreatePatternNode(""))
  547.                                 {
  548.                                     LT_SetAttributes(Handle,GAD_LIST,
  549.                                         GTLV_Labels,    ~0,
  550.                                     TAG_DONE);
  551.  
  552.                                     AddTail((struct List *)PatternList,(struct Node *)Node);
  553.  
  554.                                     LT_SetAttributes(Handle,GAD_LIST,
  555.                                         GTLV_Labels,    PatternList,
  556.                                         GTLV_Selected,    ListCount++,
  557.                                     TAG_DONE);
  558.  
  559.                                     LT_SetAttributes(Handle,GAD_PATTERN,
  560.                                         GTST_String,    "",
  561.                                         GA_Disabled,    FALSE,
  562.                                     TAG_DONE);
  563.  
  564.                                     LT_SetAttributes(Handle,GAD_COMMENT,
  565.                                         GTST_String,    "",
  566.                                         GA_Disabled,    FALSE,
  567.                                     TAG_DONE);
  568.  
  569.                                     LT_SetAttributes(Handle,GAD_REMOVE,
  570.                                         GA_Disabled,    &Selected -> List == ChosenPattern,
  571.                                     TAG_DONE);
  572.  
  573.                                     LT_SetAttributes(Handle,GAD_EDIT,
  574.                                         GA_Disabled,    &Selected -> List == ChosenPattern,
  575.                                     TAG_DONE);
  576.  
  577.                                     LT_SetAttributes(Handle,GAD_SAVE,
  578.                                         GA_Disabled,    FALSE,
  579.                                     TAG_DONE);
  580.  
  581.                                     LT_SetAttributes(Handle,GAD_CLEAR,
  582.                                         GA_Disabled,    FALSE,
  583.                                     TAG_DONE);
  584.  
  585.                                     Selected = Node;
  586.  
  587.                                     Offset = ListCount - 1;
  588.  
  589.                                     LT_SetAttributes(Handle,GAD_TOP,
  590.                                         GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  591.                                     TAG_DONE);
  592.  
  593.                                     LT_SetAttributes(Handle,GAD_UP,
  594.                                         GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  595.                                     TAG_DONE);
  596.  
  597.                                     LT_SetAttributes(Handle,GAD_DOWN,
  598.                                         GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  599.                                     TAG_DONE);
  600.  
  601.                                     LT_SetAttributes(Handle,GAD_END,
  602.                                         GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  603.                                     TAG_DONE);
  604.  
  605.                                     LT_Activate(Handle,GAD_COMMENT);
  606.  
  607.                                     PatternsChanged = TRUE;
  608.                                 }
  609.                                 else
  610.                                     DisplayBeep(LocalWindow -> WScreen);
  611.  
  612.                                 break;
  613.  
  614.                             case GAD_CLEAR:
  615.  
  616.                                 LT_SetAttributes(Handle,GAD_LIST,
  617.                                     GTLV_Labels,    ~0,
  618.                                 TAG_DONE);
  619.  
  620.                                 FreeList((struct List *)PatternList);
  621.  
  622.                                 ListCount = 0;
  623.  
  624.                                 LT_SetAttributes(Handle,GAD_LIST,
  625.                                     GTLV_Labels,    PatternList,
  626.                                     GTLV_Selected,    ~0,
  627.                                 TAG_DONE);
  628.  
  629.                                 Selected = NULL;
  630.  
  631.                                 LT_SetAttributes(Handle,GAD_TOP,
  632.                                     GA_Disabled,    TRUE,
  633.                                 TAG_DONE);
  634.  
  635.                                 LT_SetAttributes(Handle,GAD_UP,
  636.                                     GA_Disabled,    TRUE,
  637.                                 TAG_DONE);
  638.  
  639.                                 LT_SetAttributes(Handle,GAD_DOWN,
  640.                                     GA_Disabled,    TRUE,
  641.                                 TAG_DONE);
  642.  
  643.                                 LT_SetAttributes(Handle,GAD_END,
  644.                                     GA_Disabled,    TRUE,
  645.                                 TAG_DONE);
  646.  
  647.                                 LT_SetAttributes(Handle,GAD_REMOVE,
  648.                                     GA_Disabled,    TRUE,
  649.                                 TAG_DONE);
  650.  
  651.                                 LT_SetAttributes(Handle,GAD_EDIT,
  652.                                     GA_Disabled,    TRUE,
  653.                                 TAG_DONE);
  654.  
  655.                                 LT_SetAttributes(Handle,GAD_COMMENT,
  656.                                     GTST_String,    "",
  657.                                     GA_Disabled,    TRUE,
  658.                                 TAG_DONE);
  659.  
  660.                                 LT_SetAttributes(Handle,GAD_PATTERN,
  661.                                     GTST_String,    "",
  662.                                     GA_Disabled,    TRUE,
  663.                                 TAG_DONE);
  664.  
  665.                                 LT_SetAttributes(Handle,GAD_SAVE,
  666.                                     GA_Disabled,    TRUE,
  667.                                 TAG_DONE);
  668.  
  669.                                 LT_SetAttributes(Handle,GAD_CLEAR,
  670.                                     GA_Disabled,    TRUE,
  671.                                 TAG_DONE);
  672.  
  673.                                 PatternsChanged = FALSE;
  674.  
  675.                                 break;
  676.  
  677.                             case GAD_EDIT:
  678.  
  679.                                 if(Selected)
  680.                                 {
  681.                                     LT_LockWindow(LocalWindow);
  682.  
  683.                                     PatternsChanged |= RatePanel(LocalWindow,PhoneList,NULL,&Selected -> List);
  684.  
  685.                                     LT_UnlockWindow(LocalWindow);
  686.                                 }
  687.  
  688.                                 break;
  689.  
  690.                             case GAD_REMOVE:
  691.  
  692.                                 if(Selected)
  693.                                 {
  694.                                     LT_SetAttributes(Handle,GAD_LIST,
  695.                                         GTLV_Labels,    ~0,
  696.                                     TAG_DONE);
  697.  
  698.                                     if(--ListCount)
  699.                                     {
  700.                                         if(Selected -> Node . ln_Succ -> ln_Succ)
  701.                                             Node = (struct PatternNode *)Selected -> Node . ln_Succ;
  702.                                         else
  703.                                         {
  704.                                             Node = (struct PatternNode *)Selected -> Node . ln_Pred;
  705.  
  706.                                             Offset = 0;
  707.                                         }
  708.                                     }
  709.  
  710.                                     Remove((struct Node *)Selected);
  711.  
  712.                                     DeletePatternNode(Selected);
  713.  
  714.                                     LT_SetAttributes(Handle,GAD_LIST,
  715.                                         GTLV_Labels,    PatternList,
  716.                                         GTLV_Selected,    Node -> Node . ln_Succ ? GetNodeOffset((struct Node *)Node,(struct List *)PatternList) : ~0,
  717.                                     TAG_DONE);
  718.  
  719.                                     if(!ListCount)
  720.                                     {
  721.                                         Selected = NULL;
  722.  
  723.                                         LT_SetAttributes(Handle,GAD_TOP,
  724.                                             GA_Disabled,    TRUE,
  725.                                         TAG_DONE);
  726.  
  727.                                         LT_SetAttributes(Handle,GAD_UP,
  728.                                             GA_Disabled,    TRUE,
  729.                                         TAG_DONE);
  730.  
  731.                                         LT_SetAttributes(Handle,GAD_DOWN,
  732.                                             GA_Disabled,    TRUE,
  733.                                         TAG_DONE);
  734.  
  735.                                         LT_SetAttributes(Handle,GAD_END,
  736.                                             GA_Disabled,    TRUE,
  737.                                         TAG_DONE);
  738.  
  739.                                         LT_SetAttributes(Handle,GAD_REMOVE,
  740.                                             GA_Disabled,    TRUE,
  741.                                         TAG_DONE);
  742.  
  743.                                         LT_SetAttributes(Handle,GAD_EDIT,
  744.                                             GA_Disabled,    TRUE,
  745.                                         TAG_DONE);
  746.  
  747.                                         LT_SetAttributes(Handle,GAD_COMMENT,
  748.                                             GTST_String,    "",
  749.                                             GA_Disabled,    TRUE,
  750.                                         TAG_DONE);
  751.  
  752.                                         LT_SetAttributes(Handle,GAD_PATTERN,
  753.                                             GTST_String,    "",
  754.                                             GA_Disabled,    TRUE,
  755.                                         TAG_DONE);
  756.  
  757.                                         LT_SetAttributes(Handle,GAD_SAVE,
  758.                                             GA_Disabled,    TRUE,
  759.                                         TAG_DONE);
  760.  
  761.                                         LT_SetAttributes(Handle,GAD_CLEAR,
  762.                                             GA_Disabled,    TRUE,
  763.                                         TAG_DONE);
  764.                                     }
  765.                                     else
  766.                                     {
  767.                                         Selected = Node;
  768.  
  769.                                         LT_SetAttributes(Handle,GAD_PATTERN,
  770.                                             GTST_String,    Selected -> Pattern,
  771.                                         TAG_DONE);
  772.  
  773.                                         LT_SetAttributes(Handle,GAD_COMMENT,
  774.                                             GTST_String,    Selected -> Comment,
  775.                                         TAG_DONE);
  776.  
  777.                                         LT_SetAttributes(Handle,GAD_TOP,
  778.                                             GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  779.                                         TAG_DONE);
  780.  
  781.                                         LT_SetAttributes(Handle,GAD_UP,
  782.                                             GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  783.                                         TAG_DONE);
  784.  
  785.                                         LT_SetAttributes(Handle,GAD_DOWN,
  786.                                             GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  787.                                         TAG_DONE);
  788.  
  789.                                         LT_SetAttributes(Handle,GAD_END,
  790.                                             GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  791.                                         TAG_DONE);
  792.                                     }
  793.  
  794.                                     PatternsChanged = TRUE;
  795.                                 }
  796.  
  797.                                 break;
  798.  
  799.                             case GAD_LIST:
  800.  
  801.                                 if(Selected = (struct PatternNode *)GetListNode(MsgCode,(struct List *)PatternList))
  802.                                 {
  803.                                     Offset = MsgCode;
  804.  
  805.                                     LT_SetAttributes(Handle,GAD_COMMENT,
  806.                                         GTST_String,    Selected -> Comment,
  807.                                         GA_Disabled,    FALSE,
  808.                                     TAG_DONE);
  809.  
  810.                                     LT_SetAttributes(Handle,GAD_PATTERN,
  811.                                         GTST_String,    Selected -> Pattern,
  812.                                         GA_Disabled,    FALSE,
  813.                                     TAG_DONE);
  814.  
  815.                                     LT_SetAttributes(Handle,GAD_REMOVE,
  816.                                         GA_Disabled,    &Selected -> List == ChosenPattern,
  817.                                     TAG_DONE);
  818.  
  819.                                     LT_SetAttributes(Handle,GAD_EDIT,
  820.                                         GA_Disabled,    &Selected -> List == ChosenPattern,
  821.                                     TAG_DONE);
  822.  
  823.                                     LT_SetAttributes(Handle,GAD_TOP,
  824.                                         GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  825.                                     TAG_DONE);
  826.  
  827.                                     LT_SetAttributes(Handle,GAD_UP,
  828.                                         GA_Disabled,    !Selected -> Node . ln_Pred -> ln_Pred,
  829.                                     TAG_DONE);
  830.  
  831.                                     LT_SetAttributes(Handle,GAD_DOWN,
  832.                                         GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  833.                                     TAG_DONE);
  834.  
  835.                                     LT_SetAttributes(Handle,GAD_END,
  836.                                         GA_Disabled,    !Selected -> Node . ln_Succ -> ln_Succ,
  837.                                     TAG_DONE);
  838.                                 }
  839.  
  840.                                 break;
  841.  
  842.                             case GAD_COMMENT:
  843.  
  844.                                 if(Selected)
  845.                                 {
  846.                                     LT_SetAttributes(Handle,GAD_LIST,
  847.                                         GTLV_Labels,    ~0,
  848.                                     TAG_DONE);
  849.  
  850.                                     strcpy(Selected -> Comment,LT_GetString(Handle,GAD_COMMENT));
  851.  
  852.                                     LT_SetAttributes(Handle,GAD_LIST,
  853.                                         GTLV_Labels,    PatternList,
  854.                                         GTLV_Selected,    GetNodeOffset((struct Node *)Selected,(struct List *)PatternList),
  855.                                     TAG_DONE);
  856.  
  857.                                     LT_SetAttributes(Handle,GAD_PATTERN,
  858.                                         GTST_String,    Selected -> Pattern,
  859.                                     TAG_DONE);
  860.  
  861.                                     LT_SetAttributes(Handle,GAD_COMMENT,
  862.                                         GTST_String,    Selected -> Comment,
  863.                                     TAG_DONE);
  864.  
  865.                                     PatternsChanged = TRUE;
  866.  
  867.                                     LT_Activate(Handle,GAD_PATTERN);
  868.                                 }
  869.  
  870.                                 break;
  871.  
  872.                             case GAD_PATTERN:
  873.  
  874.                                 if(Selected)
  875.                                 {
  876.                                     strcpy(Selected -> Pattern,LT_GetString(Handle,GAD_PATTERN));
  877.  
  878.                                     PatternsChanged = TRUE;
  879.                                 }
  880.  
  881.                                 break;
  882.  
  883.                             case GAD_LOAD:
  884.  
  885.                                 SplitFileName(LastPattern,&DummyChar,DummyBuffer);
  886.  
  887.                                 LT_LockWindow(LocalWindow);
  888.  
  889.                                 if(FileRequest = GetFile(LocalWindow,LocaleString(MSG_AREACODE_LOAD_GROUP_SETTINGS_TXT),DummyBuffer,FilePart(LastPattern),DummyBuffer,"#?.prefs",FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_LOAD_TXT),TRUE))
  890.                                 {
  891.                                     struct List *SomeList;
  892.  
  893.                                     LT_SetAttributes(Handle,GAD_LIST,
  894.                                         GTLV_Labels,    ~0,
  895.                                     TAG_DONE);
  896.  
  897.                                     Selected = NULL;
  898.  
  899.                                     if(!(SomeList = LoadTimeDateList(DummyBuffer,&Error)))
  900.                                         ShowError(LocalWindow,ERR_LOAD_ERROR,Error,DummyBuffer);
  901.                                     else
  902.                                     {
  903.                                         DeletePatternList(PatternList);
  904.  
  905.                                         PatternList = SomeList;
  906.  
  907.                                         strcpy(LastPattern,DummyBuffer);
  908.  
  909.                                         PatternsChanged = FALSE;
  910.                                     }
  911.  
  912.                                     LT_SetAttributes(Handle,GAD_LIST,
  913.                                         GTLV_Labels,    PatternList,
  914.                                     TAG_DONE);
  915.  
  916.                                     LT_SetAttributes(Handle,GAD_PATTERN,
  917.                                         GTST_String,    "",
  918.                                         GA_Disabled,    TRUE,
  919.                                     TAG_DONE);
  920.  
  921.                                     LT_SetAttributes(Handle,GAD_COMMENT,
  922.                                         GTST_String,    "",
  923.                                         GA_Disabled,    TRUE,
  924.                                     TAG_DONE);
  925.  
  926.                                     LT_SetAttributes(Handle,GAD_REMOVE,
  927.                                         GA_Disabled,    TRUE,
  928.                                     TAG_DONE);
  929.  
  930.                                     LT_SetAttributes(Handle,GAD_EDIT,
  931.                                         GA_Disabled,    TRUE,
  932.                                     TAG_DONE);
  933.  
  934.                                     LT_SetAttributes(Handle,GAD_TOP,
  935.                                         GA_Disabled,    TRUE,
  936.                                     TAG_DONE);
  937.  
  938.                                     LT_SetAttributes(Handle,GAD_UP,
  939.                                         GA_Disabled,    TRUE,
  940.                                     TAG_DONE);
  941.  
  942.                                     LT_SetAttributes(Handle,GAD_DOWN,
  943.                                         GA_Disabled,    TRUE,
  944.                                     TAG_DONE);
  945.  
  946.                                     LT_SetAttributes(Handle,GAD_END,
  947.                                         GA_Disabled,    TRUE,
  948.                                     TAG_DONE);
  949.  
  950.                                     LT_SetAttributes(Handle,GAD_SAVE,
  951.                                         GA_Disabled,    !ListCount,
  952.                                     TAG_DONE);
  953.  
  954.                                     LT_SetAttributes(Handle,GAD_CLEAR,
  955.                                         GA_Disabled,    !ListCount,
  956.                                     TAG_DONE);
  957.  
  958.                                     FreeAslRequest(FileRequest);
  959.                                 }
  960.  
  961.                                 LT_UnlockWindow(LocalWindow);
  962.  
  963.                                 break;
  964.  
  965.                             case GAD_SAVE:
  966.  
  967.                                 SplitFileName(LastPattern,&DummyChar,DummyBuffer);
  968.  
  969.                                 LT_LockWindow(LocalWindow);
  970.  
  971.                                 if(FileRequest = GetFile(LocalWindow,LocaleString(MSG_AREACODE_SAVE_GROUP_SETTINGS_TXT),DummyBuffer,FilePart(LastPattern),DummyBuffer,"#?.prefs",TRUE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SAVE_TXT),TRUE))
  972.                                 {
  973.                                     if(!SaveTimeDateList(DummyBuffer,PatternList,&Error))
  974.                                         ShowError(LocalWindow,ERR_SAVE_ERROR,Error,DummyBuffer);
  975.                                     else
  976.                                     {
  977.                                         strcpy(LastPattern,DummyBuffer);
  978.  
  979.                                         PatternsChanged = FALSE;
  980.                                     }
  981.  
  982.                                     FreeAslRequest(FileRequest);
  983.                                 }
  984.  
  985.                                 LT_UnlockWindow(LocalWindow);
  986.  
  987.                                 break;
  988.                         }
  989.                     }
  990.                 }
  991.             }
  992.             while(!Done);
  993.  
  994.             PopWindow();
  995.         }
  996.  
  997.         LT_DeleteHandle(Handle);
  998.     }
  999.  
  1000.     if(PhoneList)
  1001.         DeletePhoneList(PhoneList);
  1002. }
  1003.